<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      >
    <h:head>
        <title>Mein Wiki Artikel editieren</title>
        <h:outputStylesheet library="css" name="stylesheet.css"/>
        <h:outputScript library="js" name="jquery-1.11.0.min.js"/>
        <h:outputScript library="js" name="slider.js"/>
    </h:head>

    <h:body>
        
        <div id="wrapper">             
           <div id="suche">
                <h:form>
                    <h:inputText id="name" value="#{articleBean.searchText}" required="true" requiredMessage="Keine Eingabe im Suchfeld" styleClass="inputSearch" maxlength="100" autocomplete="on" />
                    <h:commandButton id="cmd" value="Suchen" action="#{articleBean.search()}" styleClass="button" />
                </h:form>
            </div>
            <h:column rendered="#{!user.user}">
                <div id="login">
                    <h:form>
                        <h:commandButton id="cmd" value="Login" action="#{articleBean.goLogin()}" styleClass="button" />
                    </h:form>
                  
                </div>
                <div id="regist">
                     <h:form>
                        <h:commandButton id="cmd" value="Registrieren" action="#{articleBean.toRegist()}" styleClass="button" />
                    </h:form>
                </div>
            </h:column>
            <h:column rendered="#{user.user}">
            <div id="ausloggen">
                <h:form>
                    <h:commandButton value="Ausloggen" action="#{userBean.logout(user)}" styleClass="button"/>
                </h:form>
            </div>
            </h:column>

            <div id="header">
                <h:form>
                    <h:commandLink action="#{articleBean.goIndex()}">
                        <h:graphicImage styleClass="image"  library="images" name="LOGO-WIKI.jpg" alt="MeinWiki"/>
                    </h:commandLink>
                </h:form>
            </div>
            <div id="menue">
                <h:form>
               <div id="links">
                   <h:commandButton action="#{articleBean.random()}" value="Zufälliger Artikel" styleClass="links">

                   </h:commandButton>
                </div>
                <div id="links">
                    <h:commandButton action="#{articleBean.latestArticle()}" value="Neuster Artikel" styleClass="links" >

                    </h:commandButton>
                    
                </div>
                    <h:column rendered="#{user.boss}">
                    <div id="links">
                    <h:commandButton value="Artikel Erstellen" action="#{articleBean.create()}" styleClass="links" />
                    </div>
                        </h:column>
                </h:form>
            </div>
            
            <div id="content2">
                
                <h1>#{articleBean.article.theme}</h1>
                    <!-- Artikel ID: #{articleBean.article.id} -->
                <h:form>    
                <ui:repeat var="posts" value="#{articleBean.versionPost.posts}"> 
                   
                    <div id="boxes">

                        <h3>#{posts.subheading}</h3><br/>
                        <h:column rendered="#{user.boss}">
                        <h4 class="edit">
                            <h:commandLink action="#{articleBean.edit(posts)}">
                                <h:outputText value="Bearbeiten"/><br />                      
                                <f:param name="versionid" value="#{articleBean.versionPost.versionNumber}"/>
                                <f:param name="id" value="#{articleBean.article.id}"/>
                            </h:commandLink>
                        </h4>
                        </h:column>
                        <br/>
                        <div style="white-space: pre-wrap">
                            <ui:repeat var="post_Link" value="#{articleBean.getPostLinkPost(posts.post)}">
                                <ui:param name="Link" value="#{articleBean.checkLink(post_Link)}" />
                                
                                <h:outputText rendered="#{!Link}" escape="false" value="#{post_Link}"/>
                               
                                <h:panelGroup rendered="#{Link}" >
                                    
                                    <ui:param name="LinkName" value="#{articleBean.convertLink(post_Link)}" />
                                   
                                    <h:commandLink  action="#{articleBean.search()}">
                                        <h:outputText  value="#{LinkName}" styleClass="linkText"/>
                                        <f:param name="searchText" value="#{LinkName}"/>
                                        <f:param name="versionid" value="#{articleBean.versionPost.versionNumber}"/>
                                        <f:param name="id" value="#{articleBean.article.id}"/>
                                        </h:commandLink>
                                   
                                 </h:panelGroup>
                            </ui:repeat>
                            </div>
                        <p class="info">Version: #{posts.post_versionNumber}<br/>
                        Autor: #{posts.creator.user_name}</p>
                                                   
                    </div>
                </ui:repeat>
                    <br/>
                <div id="hinzufuegen">
                    <h4 class="edit">
                        <h:commandButton rendered="#{user.boss}" value="Hinzufügen" action="#{articleBean.addPost()}" styleClass="button">              
                            <f:param name="versionid" value="#{articleBean.versionPost.versionNumber}"/>
                            <f:param name="id" value="#{articleBean.article.id}"/>
                        </h:commandButton>
                    </h4>
                </div>
                    
                <div id="zurueck">
                     <h:form>
                         <h:commandButton value="Startseite" action="#{articleBean.goBack()}" styleClass="button">
                         <f:param name="id" value="#{articleBean.article.id}"/>
                         </h:commandButton>            
                     </h:form>
                </div>
                    <br/> 
                </h:form>
            </div>
                
            <div id="versionen">
            <h:form>
                <div class="SlideHeader">
                    <p style="font-size: 14px; color: #8898BF; display: inline; font-weight: 600">»Versionen</p>
                </div>
                <div class="SlideText">
                    <ui:repeat var="row3" value="#{articleBean.article.versions}"> 

                        <div>

                            <h:commandLink action="#{articleBean.refreshVersion()}">
                                <h:outputText value="Version: #{row3.versionNumber} - Datum: #{row3.date}"/><br />
                                <f:param name="versionid" value="#{row3.versionNumber}"/>
                                <f:param name="id" value="#{articleBean.article.id}"/>
                            </h:commandLink> 



                        </div>

                    </ui:repeat>
                </div>
                </h:form>
            </div>
            <div id="footer">
                <h:form>
                    <div id="footerlinks">
                        <h:commandLink action="#{articleBean.goImpressum()}">
                            <h:outputText value="Impressum"/>
                        </h:commandLink>
                    </div>
                    <div id="footerlinks">
                        <h:commandLink action="#{articleBean.goKontakt()}">
                            <h:outputText value="Kontakt"/>
                        </h:commandLink>
                    </div>
                </h:form>
            </div>
                
        </div>
        
    </h:body>
</html>
